package chaw.android.train.MoreActivities;

import chaw.android.train.MoreActivity;
import chaw.android.train.R;
import chaw.android.train.TrainTravelActivity;
import chaw.android.util.ServerURL;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageView;

@SuppressLint("SetJavaScriptEnabled")
public class MoreHelpActivity extends Activity {
	private WebView moreHelpWebView;
	private WebViewClient client;
	private ImageView btnBack;
	private Button btnPrivacy, btnTerms;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.more_help);
		
		moreHelpWebView = (WebView) findViewById(R.id.moreHelpWebView);
        client = new WebViewClient();
		String url = ServerURL.moreHelpWebView;
		
		moreHelpWebView.setWebViewClient(client);
		moreHelpWebView.loadUrl(url);
		moreHelpWebView.getSettings().setJavaScriptEnabled(true);
		
		btnBack = (ImageView) findViewById(R.id.btnBack);
		btnBack.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				MoreActivity parentActivity = (MoreActivity)getParent();
				parentActivity.finishFromChild(MoreHelpActivity.this);
			}
		});
		
		btnPrivacy = (Button) findViewById(R.id.btnPrivacy);
		btnTerms = (Button) findViewById(R.id.btnTerms);
		
		btnPrivacy.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				MoreActivity parentActivity = (MoreActivity)getParent();
				parentActivity.startChildActivity("moreHelpPrivacy", new Intent(getBaseContext(), MoreHelpPrivacyActivity.class));
			}
		});
		
		btnTerms.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				MoreActivity parentActivity = (MoreActivity)getParent();
				parentActivity.startChildActivity("moreHelpTerms", new Intent(getBaseContext(), MoreHelpTermsActivity.class));
			}
		});
	}
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		for(int i = 0 ; i < 5; i++)
        	TrainTravelActivity.tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.bg_nav1);
	}
}
